package com.xc.controller;

import com.xc.common.ServerResponse;
import com.xc.service.IPayService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

/**
 * @author mipha
 * @version 1.0
 * @date 2019/3/18 9:56 PM
 */
@Controller
@RequestMapping("/api/pay/")
@Slf4j
public class PayApiController {

    @Autowired
    IPayService iPayService;

    /**
     *  第一个支付渠道的通知
     * @param request
     * @param response
     * @throws IOException
     */
    @RequestMapping("juhe1Notify.do")
    @ResponseBody
    public void juhe1Notify(HttpServletRequest request, HttpServletResponse response)throws IOException{

        ServerResponse serverResponse = iPayService.juhe1Notify(request);
        if(serverResponse.isSuccess()){
            response.getWriter().write("ok");
            log.info("第一个支付渠道的通知 返回 ok 成功");
        }else{
            log.error("juhe1Notify error Msg = {}",serverResponse.getMsg());
        }

    }




}
